package sctu.edu.java.year2016.team01.xuhanmei.day20160523.practice;

/**
 * Created by Administrator on 2016/5/23.
 */
public class directsort {
    public static void main(String[] args) {
        int a[] = new int[]{1, 9, 7, 5, 8, 44};
        System.out.println("排序前的数组是：");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + "  ");
        }


        int temp;


        for (int j = 0; j < a.length; j++) {
            temp = a[j];
            for (int k = j - 1; k >= 0 && a[k] > temp; k--) {
                a[k] = a[k + 1];
                a[k + 1] = temp;
            }
        }


        System.out.println("\n排序后的数组是:");
        for (int m = 0; m < a.length; m++) {
            System.out.print(a[m] + "  ");
        }

    }
}
